/*
    This file is part of MP3DecodeDLL for Symbian.

    MP3DecodeDLL for Symbian
    Copyright (C) 2004 Denis Mingulov <denis@mingulov.com>

    MP3DecodeDLL for Symbian is free software; you can redistribute
    it and/or modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2 of
    the License, or (at your option) any later version.

    MP3DecodeDLL for Symbian is distributed in the hope that it
    will be useful, but WITHOUT ANY WARRANTY; without even the implied
    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with MP3DecodeDLL for Symbian; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/

#ifndef MP3DECODEENGINE_H
#define MP3DECODEENGINE_H

#include <e32std.h>
#include <e32base.h>

class CMP3Decode;
class RFs;
//class MMP3DecodeNotifier;

enum TMP3DecodeEngineState
{
	EDoNothing = 0,
	EOpeningFile,
	EOpenComplete,
	EDecoding,
	EPause,
	EDecodeComplete
};

/*const TInt KDefaultInBufferSize = 4000;
const TInt KDefaultOutBufferSize = 8000;
const TInt KDefaultMaximumBuffers = 16;
*/
class CMP3DecodeEngine : public CBase
{
public:
	static CMP3DecodeEngine* NewL();
	static CMP3DecodeEngine* NewLC();
	virtual ~CMP3DecodeEngine();

	TInt OpenFile(RFs& aFileServer, const TDesC &aFileName, int mediaoffset = 0, int mediarealsize = 0);//, /*TDes &aBuffer, */MMP3DecodeNotifier *aNotifier);
	TInt CloseFile();
	TInt SetEqualizer(TInt aEq60, TInt aEq170, TInt aEq310, TInt aEq600, TInt aEq1K, TInt aEq3K, TInt aEq6K, TInt aEq12K, TInt aEq14K, TInt aEq16K, TInt aEqZero, TInt aEqDiv);
	TInt SetResampleRate(TInt aResampleRate);
	TInt DecodeOneFrame(TDes &aBuffer);
	TInt DecodeStart();
	TInt DecodeStop();
	const TDesC& GetBuffer();
	TMP3DecodeEngineState GetState();
	TInt GetFileLength();
	TInt GetFilePosition();

protected:
//	void DoCancel();
//	void RunL();
//	virtual void RunError();

private:
	CMP3DecodeEngine();
	void ConstructL();
	void ChangeState (TMP3DecodeEngineState aState);

	TFileName strFileName;
	RFs *iFileSession;

	TMP3DecodeEngineState iState;
/*
	TInt iEqualizer[10]; // 60, 170, 310, 600, 1K, 3K, 6K, 12K, 14K, 16K
	TInt iEqualizerDiv;
	TInt iEqualizerZero;
*/
	TBool bFileOpened;

//	TDes *iBuffer;
//	HBufC *iBuffer;

	CMP3Decode *iMP3Decode;
//	MMP3DecodeNotifier *iNotifier;
};

#endif
